'use strict';
	angular.module('accounting.trialpop', [])
	.controller('trialpopCtrl'
			,['$rootScope', '$scope', '$uibModalInstance','params', 'title'
			   , f])//控制器结束
    function f($rootScope, $scope, $uibModalInstance, params, title) {


		var Model = this;
		
		////////////////////启动执行开始///////////////////////////////////////////////////
		
		//试算平衡
	    Model.initTrial = function(){

	    	var options = {};
	    	options.yearPeriodNo = $scope.kjkzny;
	    	
			$.ajax({
	            type: "POST",
	            async : true,//异步（默认），同步为false
	            url: $rootScope.getProjectName() + "/accounting/periodCaption/calculate/initTrial",
	            data: JSON.stringify(options),
	            contentType: "application/json; charset=utf-8",
	            dataType: "json",
	            success: function (data) {
	                // Play with returned data in JSON format
					console.log('initTrial.data->',data);
					if(data.code==0){
						Model.dataInitTrial = data.data;
						//Model.getInfo();
					}else{
						alert(data.info);
					}
	            },
	            error: function (msg) {
	                alert('ajax调用错误信息：'+msg.responseText);
	            }
	        });
	    };
		


		////////////////////启动执行结束///////////////////////////////////////////////////
		

		
		
		//////////////////////对话框使用开始//////////////////////////////////////
		
        //模态窗口打开之后执行的事件
        $uibModalInstance.opened.then(function(){
    		//接收调用对话框的参数
            Model.title = title;  
            Model.params = params;  
            
            $scope.kjkzny = params.kjkzny;
    		Model.initTrial();
        });  
		
        Model.ok = function () {  
	    	//保存成功
	    	//打包数据
	    	var event = {};
			$uibModalInstance.close(event);  
	    };  
	    
	    Model.cancel = function () {  
	        $uibModalInstance.dismiss('cancel');  
	    };    
		//////////////////////对话框使用结束//////////////////////////////////////
	    


		
		return Model;
	    
	    
	}	
	
